
g_board = []
g_size = 8

# put queen in next cell
# if check_rules_apply
#   move_to_next_column
# else:
#    if   do we hav enader cell
#       move_to_next_row
#    else:
#       go to previous queen
#       go_to_next_row

def put_queen_in_next_cell( current_row ):
    return current_row + 1

def still_in_board(x,y):
    return 0 < x < g_size and 0 < y < g_size

# x,y - new queen position
def check_rules_apply( row, column):
    for i in range(0, g_size):
        if g_board[row][i] == 1 and i != column:
            return False

    # check cross
    x = column
    y = row

    while still_in_board(x,y):
        if g_board[x][y] == 1:
            return False
        x = x - 1
        y = y - 1


    x = column
    y = row

    while still_in_board(x,y):
        if g_board[x][y] == 1:
            return False
        x = x + 1
        y = y + 1

    x = column
    y = row

    while still_in_board(x,y):
        if g_board[x][y] == 1:
            return False
        x = x + 1
        y = y - 1


    x = column
    y = row

    while still_in_board(x,y):
        if g_board[x][y] == 1:
            return False
        x = x - 1
        y = y + 1



def solve_problem( current_column, current_row ):
    g_board[current_row][current_column] = 1
    if  check_rules_apply( current_row, current_column ):
        solve_problem( current_column + 1, 0  )
    else:
        if current_row < 8:
            solve_problem( current_column, current_row + 1 )
        else:
            return

def init_board():
    for i in range (0, g_size):
        g_board.append([0] * 8)
def print_board():
    for i in range (0, g_size):
        print(g_board[i])



init_board()
solve_problem( 0 , 0 )
print_board()
  